package com.mvc.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
//@Controller是为了让Spring IOC容器初始化时自动扫描到；
@RequestMapping("/HelloController")
//@RequestMapping是为了映射请求路径，这里因为类与方法上都有映射所以访问时应该是/HelloController/hello；
public class HelloController {
    //真实访问地址：项目名/HelloController/hello
    @RequestMapping("/hello")
    public String sayHello(Model model){
        //向模型中添加属性msg与值，可以在JSP页面中取出并渲染
        model.addAttribute("msg","Hello,SpringMVC");
        //web-inf/jsp/hello.jsp
        return "hello";
    }

}
